<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');
/*****
  * The Assets helper returns xHTML 1.0 valid code to easily load CSS, image, and JavaScript files
  * @author     Michael Wales
  * @email      webmaster@michaelwales.com
  * @filename   asset_helper.php
  * @title      Asset Helper
  * @url        http://www.michaelwales.com/
  * @version    1.0
  *****/



	/***
	Returns an xHTML LINK tag for a stylesheet
        * @param    $filename string        The filename stored in the /assets/css/ directory
        * @return   string
	 ***/
	function css_asset($filename = '', $media='all') {
		if ($filename != '') {
			return '<link rel="stylesheet" type="text/css" href="' . base_url() . 'assets/css/' . $filename . '" media="' . $media . '" />' . "\n";
		}
	}
	
	/***
	Returns an xHTML IMG tag for an image
        * @param    $filename string        The filename stored in the /assets/img/ directory
        * @param    $title string           Text to use in the ALT and TITLE parameters
        * @param    $params array           Additional parameters
        * @return   string
	 ***/
	function img_asset($filename = '', $title = '', $params = array()) {
		if ($filename != '') {
			$properties = '';
			if ($params) {
				foreach ($params as $param_name => $param_val) {
					$properties .= ' ' . $param_name . '="' . $param_val . '"';
				}
			}
			return '<img src="' . base_url() . 'assets/img/' . $filename . '" alt="' . $title . '" title="' . $title . '"' . $properties . ' />';
		}
	}

	/***
	Returns an xHTML SCRIPT tag for a javascript file
        * @param    $filename string        The filename stored in the /assets/js/ directory
        * @return   string
	***/
	function js_asset($filename = '') {
		if ($filename != '') {
			return '<script type="text/javascript" src="' . base_url() . 'assets/js/' . $filename . '"></script>' . "\n";
		}
	}